package it.eng.area118.mdogpscollector.service;

import it.eng.area118.mdogpscollector.model.CheckPoint;
import android.os.Environment;

public class CheckPointStoreService extends AbstractStoreService<CheckPoint> {

	private static CheckPointStoreService service;

	public CheckPointStoreService(String file) {
		super(file, CheckPoint.class);
	}

	public synchronized static CheckPointStoreService getService() {
		if (service == null) {
			String basePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
			service = new CheckPointStoreService(basePath + "/db.dbs");
		}
		return service;
	}

	public void update(CheckPoint detachedObj, CheckPoint fromDb) {
		updateSmipleField("type", detachedObj, fromDb);
		updateSmipleField("direction", detachedObj, fromDb);
		fromDb.setLocation(detachedObj.getLocation());

	}
}
